import numpy as np
import base64
import requests
import time
import base64
import os

path = 'D:/pycharm_project/YITUYAN/capture_image'
url = 'http://192.168.1.160:21100/face/v1/face_image_flow'
camera_id = 222
count = 0
for img_name in os.listdir(path):
	count += 1
	print(count)
	if count < 406:
		continue

	img_path = os.path.join(path, img_name)

	with open(img_path, 'rb') as f:
		base64_data = base64.b64encode(f.read())
		face_image_content_base64 = base64_data.decode()
		data = {
			"face_image_content_base64": face_image_content_base64,
			"timestamp": int(time.time()),
			"camera_id": camera_id
		}
		print(requests.post(url=url, json=data).text[:])
		time.sleep(0.5)

# images = np.load(r'G:\face_0.pkg', allow_pickle=True)
# print(len(images))
# camera_id = 186
#
# gIndex = 0
# for image in images:
# 	gIndex += 1
# 	if gIndex < 0:
# 		continue
# 	t = image['face_id'][:19]
# 	t = time.strptime(t, "%Y_%m_%d_%H_%M_%S")
# 	t = time.mktime(t)
# 	print(gIndex, t)
# 	face_image_content_base64 = base64.b64encode(image['bytes']).decode()
#
# 	data = {
# 		"face_image_content_base64": face_image_content_base64,
# 		"timestamp": t,
# 		"camera_id": camera_id
# 	}
# 	print(requests.post(url=url, json=data).text[:])
# 	time.sleep(1)
# 	if gIndex > 10000:
# 		break